
************************************************************************************************************************************************
****************************** REPLICATION CODE: RELIGION AND BRAZILIAN POLITICS 
****************************** 2019. Cambridge University Press
****************************** By Amy Erica Smith (amyericas@gmail.com) 

****************************** ANALYSIS OF BRAZILIAN LEGISLATIVE STUDIES DATA



****************************************** VARIABLE CODING **************************************************************************************
use "C:\Users\aesmith2\Dropbox\Work\Data\Brazilian Legislative Surveys\Data\BLS 7 waves.dta", clear
drop evangel

recode religiao_3 (1 2 = 1) (3 = 2) (9 = 3) (4 6 7 8 = 4), g(religion2)
	replace religion2 = 2 if evangelical == 1 & religion == .
	replace religion2 = 1 if evangelical == 0 & religion == .

************************************ ELECTORAL STRATEGY
recode efforts (1 = 1) (2 = 0) (8 9 = .), g(party_election)

foreach var in bases famtrad {
	recode `var' (99 = .)	
	replace `var' = (`var'-1)/9
}

	
*************************************** POLICY VIEWS, IDEOLOGY
********* abortion: 2013 only
recode aborto 9 = . 
	replace aborto = (5-aborto)/4

********* gay marriage: 2013 only
recode casament 9 = .
	g gaymarriage = (casament-1)/4
	
********* left-right self-classification
recode lrclass 99 = .
	g l1 = (lrclass-1)/9
recode l1 (0/.25 = 0) (.26/.51 . = .5) (.51/1 = 1), g(left_right)
recode l1 (0/.51 . = 0) (.51/1 = 1), g(rightist1)
recode l1 (0/.6 . = 0) (.61/1 = 1), g(rightist2)
recode l1 (0/.25 = 1) (.26/1 . = 0), g(leftist)

********* economic policy
recode econlmr 9 = .
	replace econlmr = 2-econlmr if wave == 3
	recode econlmr (1=1) (2 = .5) (3 4 = 0), g(econlmr_r)
	g econ_left = 1-econlmr_r
	
********* affirmative action
recode cot* (9 = .)
replace cotrenda = (cotrenda-1)/4
replace cotaafro = (cotaafro-1)/4


********* social policy emphasis
foreach var in saude edfund edsuper infra socpol {
	recode `var' (9 = .)
	replace `var' = (`var'-1)/4
}
egen socialspending = rowmean(saude edfund socpol cotrenda)

******** environmentalism
recode enviro (2=0) (9 = .)

factor econ_left saude edfund edsuper socpol 
egen econ_left2 = rowmean(econ_left saude edfund edsuper socpol)
	


************************************************************************************************************************************************
************************************************************************************************************************************************
****************************************** ANALYSIS ********************************************************************************************



***************************** FIGURE 9.1. POLITICAL POSITIONS OF POLITICIANS 
preserve
collapse mn1=aborto mn2=gaymarriage mn3=econ_left mn4=socialspending mn5=cotaafro mn6=enviro mn7=l1 ///
		(semean) se1=aborto se2=gaymarriage se3=econ_left se4=socialspending se5=cotaafro se6=enviro se7=l1 , by(religion2)
reshape long mn se, i(religion) j(dv)
drop if religion == .
sort dv religion
g ub = mn + 1.65*se
g lb = mn - 1.65*se
	replace lb = 0 if lb < 0
g xaxis = _n + dv-1
graph twoway (bar mn xaxis if religion == 1, lcolor(black)  fcolor(gs4)) ///
			(bar mn xaxis if religion == 2, lcolor(black) fcolor(gs8)) ///
			(bar mn xaxis if religion == 3, lcolor(black) fcolor(gs12)) ///
			(bar mn xaxis if religion == 4, lcolor(black) fcolor(gs16)) ///
			(rspike ub lb xaxis, lcolor(black)) , ///
	graphregion(fcolor(white) lcolor(black)) ///
	legend(order(1 "Catholic" 2 "Pentecostal/Evangelical" 3 "None" 4 "Other") span size(small) col(2) symxsize(7)) ///
	note("Source: Brazilian Legislative Surveys (varying years). Whiskers represent 90% confidence intervals.", span)  ///
	ytitle("Legislator Support for Policy", margin(medsmall)) ylabel(0(.25)1, gmin gmax)	///
	xlabel(2.5 "Abortion" 7.5 "Same-Sex Marriage" 12.5 "State Economic Role" 17.5 "Spending for Poor" 22.5 "Aff. Action (Race-Based)" ///
			27.5 "Environment" 32.5 "Ideological Identification (Rightist)", labsize(small)) xtitle("") xsize(6.5) 
restore	
***************************** END FIGURE 9.1: POLITICAL POSITIONS OF POLITICIANS 


***************************** FIGURE 9.2. ELECTORAL STRATEGIES
preserve
collapse mn1=famtrad mn2=party_election mn3=bases ///
		(semean) se1=famtrad se2=party_election se3=bases , by(religion2)
reshape long mn se, i(religion) j(dv)
drop if religion == .
sort dv religion
g ub = mn + 1.65*se
g lb = mn - 1.65*se
g xaxis = _n + dv-1
graph twoway (bar mn xaxis if religion == 1, lcolor(black)  fcolor(gs4)) ///
			(bar mn xaxis if religion == 2, lcolor(black) fcolor(gs8)) ///
			(bar mn xaxis if religion == 3, lcolor(black) fcolor(gs12)) ///
			(bar mn xaxis if religion == 4, lcolor(black) fcolor(gs16)) ///
			(rspike ub lb xaxis, lcolor(black)) , ///
	graphregion(fcolor(white) lcolor(black)) ///
	legend(order(1 "Catholic Legislators" 2 "Pentecostal/" "Evangelical Legislators" 3 "Non-Religious Legislators" 4 "Other Religion") ///
			span size(small) col(2) symxsize(7) width(100)) ///
	note("Source: Brazilian Legislative Surveys (varying years).", span)  ///
	ytitle("Priority Given Each Electoral Base", margin(medsmall)) ylabel(0(.25)1, gmin gmax)	///
	xlabel(2.5 "Family/Tradition" 7.5 "Party" 12.5 "Grassroots Groups" , labsize(small) notick) xtitle("")
restore	
***************************** END FIGURE 9.2. ELECTORAL STRATEGIES


